import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import {createSvgIconsPlugin} from "vite-plugin-svg-icons";

// http://192.168.156.31:2020/portal/ly/count
// https://vitejs.dev/config/
export default defineConfig(()=>{
  return{
    plugins: [vue(),
      createSvgIconsPlugin({
        iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
        symbolId: 'icon-[dir]-[name]',
      }),],

    server: {
      proxy: {
        // 使用 proxy 实例
        '/portal': {
          // target: 'http://192.168.156.31:2020',//注意这里不能用http://localhost:8889
          target: 'http://192.168.156.35:2020',//注意这里不能用http://localhost:8889
          changeOrigin: true,
          rewrite: (path) => path.replace('(/\\/portal/', '')
        },
        '/user': {
          // target: 'http://192.168.156.31:2020',//注意这里不能用http://localhost:8889
          target: 'http://192.168.156.35:2020',//注意这里不能用http://localhost:8889
          changeOrigin: true,
          rewrite: (path) => path.replace('(/\\/user/', '')
        },
        '/admin': {
          // target: 'http://192.168.156.31:2020',//注意这里不能用http://localhost:8889
          target: 'http://192.168.156.35:2020',//注意这里不能用http://localhost:8889
          changeOrigin: true,
          rewrite: (path) => path.replace('(/\\/admin/', '')
        },
        '/python': {
          target: 'http://127.0.0.1:5000',//注意这里不能用http://localhost:8889
          changeOrigin: true,
          rewrite: (path) => path.replace('(/\\/python/', '')
        },

      }
    },
    resolve: {
      alias: {
        "@": path.resolve("./src") // 相对路径别名配置，使用 @ 代替 src
      }
    },

    css: {
      preprocessorOptions: {
        scss: {
          javascriptEnabled: true,
          additionalData: '@import "./src/styles/variable.scss";',
        },
      },
    }}



})
